let disp1O = document.querySelector('.disp1')
let disp2O = document.querySelector('.disp2')
let disp3O = document.querySelector('.disp3')
let aH1O = document.querySelector('.aH1')
let aH2O = document.querySelector('.aH2')
let aH3O = document.querySelector('.aH3')
let sc = document.querySelector('.sc')
let sale = document.querySelector('.sale')
let span = document.querySelector('.span')
let fixation = document.querySelector('.fixation')
let ulDt = document.querySelectorAll('.fore1')
let unfoldO = document.querySelectorAll('.unfold')
let allf = document.querySelector('.all-f')
let all = document.querySelector('.all')


all.onmouseover=function (){
    allf.style.display = 'block'
}
all.onmouseout = function (){
    allf.style.display = 'none'
}
aH1O.onmouseenter = function(){
    aH1O.style.color = "#ff666b"
    aH1O.style.borderBottom="1px solid #ff666b"
    aH2O.style.color = "#646464"
    aH2O.style.borderBottom="none"
    aH3O.style.color = "#646464"
    aH3O.style.borderBottom="none"
    disp1O.style.display = "block"
    disp2O.style.display = "none"
    disp3O.style.display = "none"
}
aH2O.onmouseenter = function(){
    aH2O.style.color = "#ff666b"
    aH2O.style.borderBottom="1px solid #ff666b"
    aH1O.style.color = "#646464"
    aH1O.style.borderBottom="none"
    aH3O.style.color = "#646464"
    aH3O.style.borderBottom="none"
    disp1O.style.display = "none"
    disp2O.style.display = "block"
    disp3O.style.display = "none"
}
aH3O.onmouseenter = function(){
    aH3O.style.color = "#ff666b"
    aH3O.style.borderBottom="1px solid #ff666b"
    aH2O.style.color = "#646464"
    aH2O.style.borderBottom="none"
    aH1O.style.color = "#646464"
    aH1O.style.borderBottom="none"
    disp1O.style.display = "none"
    disp2O.style.display = "none"
    disp3O.style.display = "block"
}
sc.addEventListener("mouseover", fn)
function fn(){
    sale.style.display = "block"
}
sc.addEventListener("mouseout", fn1)
function fn1(){
    sale.style.display = "none"
}

for (var i = 0 ; i < ulDt.length ; i++){
    ulDt[i].setAttribute('index',i)
    ulDt[i].onmouseenter=function(e){
        let eve = e || window.event
        let that = eve.target || eve.srcElement || eve.toElement;
        let index = that.getAttribute("index")
        console.log(index)
        for(var j=0;j<unfoldO.length;j++){
            if(j===Number(index)){
                unfoldO[j].style.display="block";
            }else{
                unfoldO[j].style.display="none";
            } 
        }
    }
}

const token = sessionStorage.getItem("isLogin") ? JSON.parse(sessionStorage.getItem("isLogin")) : {};
if(token.code === "OK"){
    $(".login").hide();
    $(".user").show();
    $(".user").children("span").html(token.name)
}else{
    $(".login").show();
    $(".user").hide();
}

$(".q").click(function(){
    sessionStorage.removeItem("isLogin");
    $(".login").show();
    $(".user").hide();
})